package cn.jinjimi.app.main.widget;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.TextView;

import cn.jinjimi.app.R;
import cn.jinjimi.app.main.widget.FrescoImageView.FrescoImageView;

/**
 *
 * @author zhenhua
 * @date 2018/2/2
 */

public class EntranceView extends LinearLayout {
    private FrescoImageView mImg;
    private TextView mLabel;

    public EntranceView(Context context) {
        super(context);
        init();
    }

    public EntranceView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public EntranceView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        LayoutInflater.from(getContext()).inflate(R.layout.view_entrance, this, true);
        mImg = (FrescoImageView) findViewById(R.id.entrance_img);
        mLabel = (TextView) findViewById(R.id.entrance_label);
    }

    public void setLabel(String label) {
        if (mLabel != null) {
            mLabel.setText(label);
        }
    }

    public void setImgUrl(String imgUrl) {
        if (mImg != null) {
            mImg.loadView(imgUrl);
        }
    }
}
